﻿using System;
using System.Net;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.Collections.Generic;

namespace BasharLulu.QuranBookmark.WP7
{
    public class SuraEnglishNameConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter,
                          System.Globalization.CultureInfo culture)
        {
            string toReturn = string.Empty;
            if (targetType != typeof(string))
            {
                return toReturn;
            }

            //var xx = from App.SuraViewModel.ItemsOC
            var xxx = from sura in App.SuraViewModel.ItemsOC
                      where sura.SuraNumber == (int)value
                      select sura;

            SuraViewModel item = xxx.FirstOrDefault();

            if (item != null)
                toReturn = string.Format("{0}", item.SuraEnglishName, item.SuraNumber);

            return toReturn;
        }

        public object ConvertBack(object value, Type targetType, object parameter,
                        System.Globalization.CultureInfo culture)
        {
            return null;
        }
    }

    public class SuraArabicNameConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter,
                          System.Globalization.CultureInfo culture)
        {
            string toReturn = string.Empty;
            if (targetType != typeof(string))
            {
                return toReturn;
            }

            //var xx = from App.SuraViewModel.ItemsOC
            var xxx = from sura in App.SuraViewModel.ItemsOC
                      where sura.SuraNumber == (int)value
                      select sura;

            SuraViewModel item = xxx.FirstOrDefault();

            if (item != null)
                toReturn = string.Format("{0}", item.SuraArabicName);

            return toReturn;
        }

        public object ConvertBack(object value, Type targetType, object parameter,
                        System.Globalization.CultureInfo culture)
        {
            return null;
        }
    }

}
